<%@ page import="Contas.Administrador" %>
<%@ page import="Contas.Telefone" %>
<html>
  <head>
    <title>SPL - Resultados da Consulta</title>
	<meta name="layout" content="adminContas" />
  </head>
  <body>
    <h1>Resultados da Consulta</br></h1>
    <div class="list">
      <div align="center"><h1>Administradores</h1></br></div>
      <table>
        <thead>
          <tr>

        <g:sortableColumn property="userRealName" title="${message(code: 'administrador.userRealName.label', default: 'Nome')}" params ="${params}"/>

        <g:sortableColumn property="username" title="${message(code: 'administrador.username.label', default: 'Login')}" params ="${params}"/>

        <g:sortableColumn property="email" title="${message(code: 'administrador.email.label', default: 'Email')}" params ="${params}" />

        <g:sortableColumn property="telefone" title="${message(code: 'administrador.telefone.label', default: 'Telefone')}" params ="${params}" />

        <g:sortableColumn property="tipo" title="${message(code: 'administrador.tipo.label', default: 'Tipo')}" params ="${params}" />

        <g:sortableColumn property="description" title="Detalhes" params ="${params}" />

        </tr>
        </thead>
        <tbody>
        <g:each in="${pesquisaAdmin}" status="i" var="administradorInstance">
          <tr class="${(i % 2) == 0 ? 'odd' : 'even'}">

            <td>${fieldValue(bean: administradorInstance, field: "userRealName")}</td>

            <td>${fieldValue(bean: administradorInstance, field: "username")}</td>

            <td>${fieldValue(bean: administradorInstance, field: "email")}</td>

            <g:if test="${Contas.Telefone.get(administradorInstance.telefoneId) != null}">
                            	<td>${Contas.Telefone.get(administradorInstance.telefoneId).formatFone()}</td>
                            </g:if>
                        	<g:else>
 		                       	<td>${}</td>
                        	</g:else>

            <td>${fieldValue(bean: administradorInstance, field: "tipo")}</td>
            <td class = "actionButtons">
              <span class = "actionButton">
                <g:link action="show" id="${administradorInstance.id}">
                  Ver mais
                </g:link></span></td>
          </tr>
        </g:each>
        </tbody>
      </table>
    </div>

    <div class="paginateButtons">
      <g:paginate total="${Administrador.count()}" />
    </div>

  <g:jasperReport action="createReportAdminComplete" controller="administrador" format="PDF" jasper="Relatorio SPL - Administrador Completo" name="Relatorio SPL - PDF"/>
  <g:jasperReport action="createReportAdminComplete" controller="administrador" format="XLS" jasper="Relatorio SPL - Administrador Completo" name="Relatorio SPL - XLS"/>
  <g:jasperReport action="createReportAdminComplete" controller="administrador" format="ODT" jasper="Relatorio SPL - Administrador Completo" name="Relatorio SPL - ODT"/>
  <g:jasperReport action="createReportAdminComplete" controller="administrador" format="DOCX" jasper="Relatorio SPL - Administrador Completo" name="Relatorio SPL - DOCX"/>

  <div align="center"><br></br><g:link action='search'>Pesquisar Novamente</g:link></div>
</body>
</html>